The W3C team's head was kicked off until javascript1.8.1 supported the trim function (with trimleft and trimright). Unfortunately, only firefox3.5 supported it now. Since the blank spaces on both sides of the string are too common, all major types
In IE 7 8 browsers, if you use the trim () property to remove spaces, it can cause an error.
The solution to this problem is therefore as follows:
var AA = $ ("#id"). Val (). Trim ()---cannot resolve the trim () method in IE
Solution:
[var AA =
Achieve 1
Copy Code code as follows:
String.prototype.trim = function () {
return this. Replace (/^\s\s*/, '). Replace (/\s\s*$/, ');
}
It does not look very good, using two of regular replacements, the actual speed is
Because of the previous version of JavaScript 1.8.1, there is no built-in trim function, so JQuery has its own implementation. In different versions of jquery, the TRIM function is implemented differently.Read this article to master the use of
A set of methods for removing spaces in JavaScript. The script home has previously released a lot of code for removing spaces, which is more comprehensive. Implementation 1
The Code is as follows:
String. prototype. trim = function (){Return this.
Python is well-known for its structure, but also known for its naming conventions, chaotic and irregular naming especially for developers to bring understanding of the misunderstanding.In particular, like Python, ruby Dynamic language, the naming of
1.1. OverviewWith the rapid development of WEB2.0 and Ajax ideas on the Internet, there have been some excellent JS frames, among them the famous prototype, YUI, JQuery, MooTools, Bindows and the domestic JSVM framework, etc. By applying these JS
A summary of jquery techniquesFirst, Introduction1.1. OverviewWith the rapid development of WEB2.0 and Ajax ideas on the Internet, there have been some excellent JS frames, among them the famous prototype, YUI, JQuery, MooTools, Bindows and the
First, Introduction1.1. OverviewWith the rapid development of WEB2.0 and Ajax ideas on the Internet, there have been some excellent JS frames, among them the famous prototype, YUI, JQuery, MooTools, Bindows and the domestic JSVM framework, etc. By
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.